package DuoYingSe;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class Servle extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int a =1000;
       String requestURI = req.getRequestURI();
        PrintWriter writer = resp.getWriter();
        int i = requestURI.indexOf("/");
        String substring = requestURI.substring(i);
        if ("/vip".equals(substring)){
            writer.print(a*0.9);
        }else if ("/vvip".equals(substring)){
            writer.print(a*0.5);
        }else {
            writer.print(a);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
